from google.appengine.ext import db
from domain import discussion
from repository import baserepository

class DiscussionRepository(baserepository.BaseRepository):

    def getByType(self, type):
        discussions = db.GqlQuery("SELECT * FROM Discussion WHERE enabled=True AND type = :1 ORDER BY title", type)
        return discussions

    def getByKey(self, discussionkey):
        return super(DiscussionRepository, self).getByKey(discussionkey, discussion.Discussion)

    def save(self, newdiscussion):
        return super(DiscussionRepository, self).save(newdiscussion, discussion.Discussion)

    def delete(self, olddiscussion):
        super(DiscussionRepository, self).delete(olddiscussion, discussion.Discussion)